home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / sprite / sparc_procDebugRegs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-20  |  2.8 KB  |  106 lines

  1. /* 
  2.  * procDebugRegs.c --
  3.  *
  4.  *    Convert registers between the format expected by the ptrace system
  5.  *    call and that of the Sprite Proc_Debug call.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include "sprite.h"
  22. #include "status.h"
  23. #include "sys/ptrace.h"
  24. #include <errno.h>
  25. #include <proc.h>
  26. #include <signal.h>
  27. #include <sys/wait.h>
  28. #include "sun4.md/reg.h"
  29. #include "procDebugRegs.h"
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * procDebugToPtraceRegs --
  36.  *
  37.  *    Convert registers from a proc debug format to a ptrace format.
  38.  *
  39.  * Results:
  40.  *    None.
  41.  *
  42.  * Side effects:
  43.  *    None.
  44.  *
  45.  *----------------------------------------------------------------------
  46.  */
  47.  
  48. void
  49. procDebugToPtraceRegs(regStatePtr, ptraceRegsPtr)
  50.     Mach_RegState    *regStatePtr; /* Register state as returned by 
  51.                        * the PROC_GET_DBG_STATE argument
  52.                        * to Proc_Debug. */
  53.     char    *ptraceRegsPtr;          /* Memory to put ptrace format of
  54.                        * registers. */
  55.  
  56. {
  57.     register struct regs *regs = (struct regs *) ptraceRegsPtr;
  58.  
  59.     regs->r_psr = regStatePtr->curPsr;
  60.     regs->r_pc = regStatePtr->pc;
  61.     regs->r_npc = regStatePtr->nextPc;
  62.     regs->r_y = regStatePtr->y;
  63.     bcopy ((char *)&(regStatePtr->globals[1]), (char *) &(regs->r_g1),
  64.          7*sizeof(int));
  65.     bcopy ((char *)(regStatePtr->ins), (char *) &(regs->r_o0),
  66.          8*sizeof(int));
  67.  
  68. }
  69.  
  70.  
  71. /*
  72.  *----------------------------------------------------------------------
  73.  *
  74.  * ptraceToProcDebugRegs --
  75.  *
  76.  *    Convert registers from a ptrace format to a proc debug format.
  77.  *
  78.  * Results:
  79.  *    None.
  80.  *
  81.  * Side effects:
  82.  *    None.
  83.  *
  84.  *----------------------------------------------------------------------
  85.  */
  86.  
  87. void
  88. ptraceToProcDebugRegs(ptraceRegsPtr, regStatePtr)
  89.     char    *ptraceRegsPtr;          /* Memory image of ptrace format of
  90.                        * registers. */
  91.     Mach_RegState    *regStatePtr; /* Register state as used by Proc_Debug */
  92.  
  93. {
  94.     register struct regs *regs = (struct regs *) ptraceRegsPtr;
  95.  
  96.     regStatePtr->curPsr = regs->r_psr;
  97.     regStatePtr->pc = regs->r_pc;
  98.     regStatePtr->nextPc = regs->r_npc;
  99.     regStatePtr->y = regs->r_y;
  100.     bcopy ((char *) &(regs->r_g1), (char *)&(regStatePtr->globals[1]), 
  101.          7*sizeof(int));
  102.     bcopy ((char *) &(regs->r_o0), (char *)(regStatePtr->ins), 
  103.          8*sizeof(int));
  104. }
  105.  
  106.